#include <iostream>
using namespace std;

/*
    友元 : C++提供的一种语法机制，可以访问类中的私有成员变量和成员函数
        分类： 1.友元类  2.友元函数
        特点：1.友元不能继承 2.友元是单向的 3.友元不能传递
        友元函数：
            在类中声明友元函数
            语法：friend 返回值类型 函数名(参数列表);
*/

class Alipay
{
public:
    Alipay(string accountnum, string password, double money)
    {
        this->accountnum = accountnum;
        this->password = password;
        this->money = money;
    }
    friend void showAlipay(Alipay &alipay);
    friend void setAlipay(Alipay &alipay);

private:
    string accountnum;
    string password;
    double money;
};

void showAlipay(Alipay &alipay)
{
    cout << "账号为：" << alipay.accountnum << endl;
    cout << "密码为：" << alipay.password << endl;
    cout << "余额为：" << alipay.money << endl;
}
void setAlipay(Alipay &alipay)
{
    string a;
    cout << "请输入账号：" << endl;
    cin >> a;
    alipay.accountnum = a;
    string p;
    cout << "请输入密码：" << endl;
    cin >> p;
    alipay.password = p;
    double m;
    cout << "请输入余额：" << endl;
    cin >> m;
    alipay.money = m;
}

int main()
{
    Alipay alipay("j", "123456", 1000.0);
    setAlipay(alipay);
    showAlipay(alipay);

    return 0;
}